package com.byxy.ssm.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.byxy.ssm.mapper.UserMapper;
import com.byxy.ssm.pojo.User;
import com.byxy.ssm.service.UserService;

@Service
@Transactional
public class UserServiceImpl implements UserService {

	@Resource
	private UserMapper userMapper;

	@Override
	public int insert(User user) {
		// TODO Auto-generated method stub
		return userMapper.insert(user);
	}

	@Override
	public List<User> findAll() {
		// TODO Auto-generated method stub
		return userMapper.findAll();
	}

	@Override
	public int update(User user) {
		// TODO Auto-generated method stub
		return userMapper.update(user);
	}

	@Override
	public User getByName(User user) {
		// TODO Auto-generated method stub
		User u = userMapper.getByLogin(user);
		if (u!= null) {
				if (user.getUserName().equals(u.getUserName()) && user.getUserPassword().equals(u.getUserPassword())) {
					return u;

			}
		}
		return null;

	}

	@Override
	public User getById(Integer userId) {
		// TODO Auto-generated method stub
		return userMapper.getById(userId);
	}

	@Override
	public int updateStatus(Integer  userId,Integer userStatus) {
		// TODO Auto-generated method stub
		return userMapper.updateStatus(userId,userStatus);
	}

}
